<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('会议室申请记录列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>会议室ID：</label>
                            <input type="text" name="roomId"/>
                        </li>
                        <li>
                            <label>申请部长ID：</label>
                            <input type="text" name="ministerId"/>
                        </li>
                        <li>
                            <label>申请时间：</label>
                            <input type="text" class="time-input" placeholder="请选择申请时间" name="applicationTime"/>
                        </li>
                        <li>
                            <label>会议主题：</label>
                            <input type="text" name="meetingSubject"/>
                        </li>
                        <li>
                            <label>参会人员：</label>
                            <input type="text" name="attendees"/>
                        </li>
                        <li>
                            <label>会议开始时间：</label>
                            <input type="text" class="time-input" placeholder="请选择会议开始时间" name="meetingStartTime"/>
                        </li>
                        <li>
                            <label>会议结束时间：</label>
                            <input type="text" class="time-input" placeholder="请选择会议结束时间" name="meetingEndTime"/>
                        </li>


                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:application:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:application:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:application:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:application:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:application:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:application:remove')}]];
    var prefix = ctx + "system/application";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "会议室申请记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'applicationId',
                    title: '申请记录主键ID',
                    visible: false
                },
                {
                    field: 'roomId',
                    title: '会议室id',
                },
                {
                    field: 'ministerId',
                    title: '申请部长ID'
                },
                {
                    field: 'applicationTime',
                    title: '申请时间'
                },
                {
                    field: 'attendees',
                    title: '参会人员id',
                },
                {
                    field: 'meetingSubject',
                    title: '会议主题'
                },
                {
                    field: 'meetingStartTime',
                    title: '会议开始时间',
                    formatter: function(value, row, index) {
                        if (value) {
                            return $.common.dateFormat(value, 'yyyy-MM-dd HH:mm');
                        }
                        return "";
                    }
                },
                {
                    field: 'meetingEndTime',
                    title: '会议结束时间',
                    formatter: function(value, row, index) {
                        if (value) {
                            return $.common.dateFormat(value, 'yyyy-MM-dd HH:mm');
                        }
                        return "";
                    }
                },
                {
                    field: 'status',
                    title: '申请状态',
                    // 新增：状态字段格式化
                    formatter: function(value, row, index) {
                        if (value === '已批准') {
                            return '<span class="label label-success">已批准</span>';
                        } else if (value === '待审批') {
                            return '<span class="label label-warning">待审批</span>';
                        } else if (value === '已拒绝') {
                            return '<span class="label label-danger">已拒绝</span>';
                        }
                        return value;
                    }
                    // 新增结束
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.applicationId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.applicationId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>